package com.google.code.p.ivans;

import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.GregorianCalendar;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.code.p.ivans.entities.Waiter;
import com.google.code.p.ivans.myexceptions.EntityNotFoundException;
import com.google.code.p.ivans.serviceinterfaces.WaiterServiceInterface;
import com.google.code.p.ivans.serviceinterfacesimpls.WaiterServiceInterfaceImpl;

public class WaitersServlet extends HttpServlet {	 
       
 
    public WaitersServlet() {}
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		WaiterServiceInterface waiterServiseInterface = new WaiterServiceInterfaceImpl();
		
		List<Waiter> waiters = null;
		try {
			waiters = waiterServiseInterface.getAllWaiters();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (EntityNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}		
			
		request.setAttribute("waiters", waiters);		
		
		RequestDispatcher requestDispatcher = request.getRequestDispatcher("waiters.jsp");
		requestDispatcher.forward(request, response);		
	}
}
